{extends 'admin/layout/table-main.tpl'}

{block title}订单管理{/block}
{block smallTitle}系统内的订单管理。{/block}

{block main}
<div class="row" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
	<div class="col-sm-12">
		<div class="ibox float-e-margins">
			<div class="ibox-title">
				<h5>订单管理 <small>后台订单编辑</small></h5>
			</div>
			<div class="ibox-content">
				<form method="post" class="form-horizontal" action="{route('AdminOrderEditAction')}">
					{if $data}
					<div class="form-group">
						<label class="col-sm-2 control-label">订单号</label>
						<div class="col-sm-10">
							<p class="form-control-static">{$data.id}</p>
						</div>
					</div>
					{/if}
					<div class="form-group">
						<label class="col-sm-2 control-label">订单信息</label>
						<div class="col-sm-10">
							{if $data}
							<p>
								{$data.RedefinitionInfo}
								<br>
								{foreach $data.goods as $item}
									商品id:{$item.id}
									商品货号:{$item.goods_number}
									<br>
								{/foreach}
							</p>
							{else}
								<textarea type="text" class="form-control" name="info" ></textarea>
							{/if}
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">订单留言</label>
						<div class="col-sm-10">
							{if $data}
							<p>{$data.leave_word}</p>
							{else}
								<textarea type="text" class="form-control" name="leave_word" ></textarea>
							{/if}
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 col-sm-2 control-label">订单状态</label>
						<div class="col-sm-10">
							<select class="form-control m-b-10" name="status">
								{foreach $status as $key=>$item}
									<option value="{$key}" {if $data.status==$key}selected="selected"{/if}>{$item}</option>
								{/foreach}
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 col-sm-2 control-label">订单阶段</label>
						<div class="col-sm-10">
							<select class="form-control m-b-10" name="step">
								{foreach $step as $key=>$item}
									<option value="{$key}" {if $data.step==$key}selected="selected"{/if}>{$item}</option>
								{/foreach}
							</select>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">用户名</label>
						<div class="col-sm-10">
							<p>{$data.member.nickname}</p>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">用户手机号</label>
						<div class="col-sm-10">
							{if $data}
							<p>{$data.member.mobile}</p>
							{else}
							<input type="text" class="form-control" name="mobile" value="">
							{/if}
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">真实姓名</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" name="real_name" value="{Input::old('real_name', $data.real_name)|escape}">
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">用户归属地</label>
						<div class="col-sm-10">
							<select class="medium m-wrap" tabindex="1"
									name="province_id" id="province">
								<option value="0" >省/市</option>
								{foreach $province as $item}
									<option value="{$item.id}" {if $data.province_id==$item.id}selected="selected"{/if}>{$item.name}</option>
								{/foreach}
							</select>&nbsp;&nbsp;<select class="medium m-wrap" tabindex="1"
														 name="city_id" id="town" {if !$city}style="display:none;"{/if}>
								<option value="0" >市/地区</option>
								{foreach $city as $item}
									<option value="{$item.id}" {if $data.city_id==$item.id}selected="selected"{/if}>{$item.name}</option>
								{/foreach}
							</select>&nbsp;&nbsp;<select class="medium m-wrap" tabindex="1"
														 name="area_id" id="area" {if !$area}style="display:none;{/if}">
								<option value="0" >县/市</option>
								{foreach $area as $item}
									<option value="{$item.id}" {if $data.area_id==$item.id}selected="selected"{/if}>{$item.name}</option>
								{/foreach}
							</select>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">详细地址</label>
						<div class="col-sm-10">
							<textarea name="address" class="form-control">{Input::old('address')|default:$data.address|escape}</textarea>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">订单金额</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" name="price" value="{$data.price}">
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">付款方式</label>
						<div class="col-sm-10">
							{if $data}
							<p>{$pay_mode[$data.pay_mode]}</p>
							{else}
								<select class="form-control m-b-10" name="pay_mode">
									{foreach $pay_mode as $key=>$item}
										<option value="{$key}" {if $data.pay_mode==$key}selected="selected"{/if}>{$item}</option>
									{/foreach}
								</select>
							{/if}
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">渠道来源</label>
						<div class="col-sm-10">
							{if $data}
							<p>{$data.channel.name}</p>
							{else}
								<select class="form-control m-b-10" name="channel_id">
									<option value="" >请选择</option>
									{foreach $channel as $key=>$item}
										<option value="{$item.id}">{$item.name}</option>
									{/foreach}
								</select>
							{/if}
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">快递单号</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" name="courier_number" value="{Input::old('courier_number', $data.courier_number)|escape}">
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-2">
							<input type="hidden" class="form-control" name="id" value="{$data.id}">
							<button class="btn btn-primary" type="submit">保存内容</button>
							<a class="btn btn-white" type="button" href="javascript:;" onclick="history.go(-1)">返回</a>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
{/block}
{block script}
	<script type="text/javascript">
		$(document).ready(function() {
			$('#province').change(function() {
				var provinceID = $(this).children('option:selected').val(); //这就是selected的值
				if (provinceID > 0) {
					tmp = '<option value="0">市/地区<\/option>';
					$.ajax({
						type: "GET",
						url: "{route('AdminGlobalLocationData')}",
						data: "pid="+provinceID,
						success: function(result){
							$.each(result['data'], function(key, val) {
								tmp += '<option value="' + val.id + '" >' + val.name + '<\/option>';
							});
							$('#town').html(tmp).show();
							$('#area').html('').hide();
							tmp = '';
						}
					});
				} else {
					$('#town').html('').hide();
					$('#area').html('').hide();
				}
			});

			$('#town').change(function() {
				var townID = $(this).children('option:selected').val(); //这就是selected的值
				if (townID > 0) {
					tmp = '<option value="0">县/市<\/option>';
					$.ajax({
						type: "GET",
						url: "{route('AdminGlobalLocationData')}",
						data: "pid="+townID,
						success: function(result){
							$.each(result['data'], function(key, val) {
								tmp += '<option value="' + val.id + '" >' + val.name + '<\/option>';
							});
							$('#area').html(tmp).show();
							tmp = '';
						}
					});
				} else {
					$('#area').html('').hide();
				}
			});
		});
	</script>
{/block}
